//
//  ArticleTableViewCell.m
//  Style
//
//  Created by YL on 15/9/23.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#define ViewWidth(v)                        v.frame.size.width
#define ViewHeight(v)                       v.frame.size.height
#define ScreenWidth          [[UIScreen mainScreen] bounds].size.width
#define ScreenHeight         [[UIScreen mainScreen] bounds].size.height
#import "YLArticleTableViewCell.h"
#import "YLArticleCollectionView.h"
@implementation YLArticleTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
        [self.flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
        
        /* 更改item 大小 默认(50 * 50) */
        self.flowLayout.itemSize = CGSizeMake((ScreenWidth - 20) / 3, ScreenHeight / 6);
        
        /* 设置item上下之间的间距(最小值) */
        self.flowLayout.minimumLineSpacing = 5;
        
        /* 设置item作用之间的间距(最小值) */
        self.flowLayout.minimumInteritemSpacing = 5;
        
        /* 设置距四边的间距 */
        self.flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
        self.articleCollectionView = [[YLArticleCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowLayout];
        [self.contentView addSubview:self.articleCollectionView];
        
    }
    return self;
}

/* 布局 */
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.articleCollectionView.frame = CGRectMake(0, 0, ViewWidth(self), ViewHeight(self));
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
